package com.itqf.yun.controller;

import com.itqf.yun.dto.CommonsDto;
import com.itqf.yun.dto.SaveDto;
import com.itqf.yun.dto.UserDto;
import com.itqf.yun.pojo.User;
import com.itqf.yun.service.UserService;
import com.itqf.yun.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.security.PublicKey;

/**
 * projectName: aliyun
 *
 * @author: Ayangcx
 * time: 2021/9/28 14:43
 * description:
 */
@RestController
@CrossOrigin("*")
@RequestMapping("user")
public class UserController {
	@Autowired
	private UserService userService;

	/**
	 * 登录接口
	 * @param userDto
	 * @return
	 */
	@PostMapping("login")
	public Object login (@RequestBody UserDto userDto) {
		R r = userService.login(userDto);
		return r;
	}

	/**
	 * 注册接口
	 * @param saveDto
	 * @return
	 */
	@PostMapping("save")
	public Object save (@RequestBody SaveDto saveDto){
		R r = userService.save(saveDto);
		return r;
	}

	/**
	 * 用户列表
	 * @return
	 */
	@GetMapping("list")
	public Object list () {
		R r = userService.list();
		return r;
	}

	@PostMapping("update")
	public Object update (@RequestBody User user) {
		R r = userService.update(user);
		return r;
	}
	/**
	 * 删除用户
	 * @param uid
	 * @return
	 */
	@GetMapping("remove")
	public Object remove(int uid){
		R r = userService.remove(uid);
		return r;
	}
	@PostMapping("change")
	public Object change(@RequestBody CommonsDto commonsDto){
		R r = userService.change(commonsDto);
		return r;
	}
}
